/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.managed;

import beans.ejb.FantasyteamFacade;
import entities.Fantasyteam;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author The Lunatics
 */
@Named(value = "standing")
@SessionScoped
public class Standing implements Serializable {

    @EJB
    private FantasyteamFacade fantasyteamFacade;
    private List<Fantasyteam> teams;

    public List<Fantasyteam> getTeams() {
        System.err.println("Get Teams in Standing");
        if (teams == null) {
            FacesContext context = FacesContext.getCurrentInstance();
            HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
            AccountBean account = ((AccountBean) request.getSession().getAttribute("accountBean"));
            teams = fantasyteamFacade.getAllTeams(account.getCurrentLeague());
        }
        return teams;
    }

    public void setTeams(List<Fantasyteam> teams) {
        this.teams = teams;
    }

    /**
     * Creates a new instance of Standing
     */
    public Standing() {
    }
}
